import axios from './axios'
import qs from 'qs'
import {baseUrl} from '@/config/config'

export const getBuildTree = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: baseUrl + '/dorm/api/app/build/buildingTreeByUseList',
            method: 'get',
            params
        }).then(res => {
          resolve(res.data)
        })
    })
}

export const getDormTree = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: baseUrl + '/dorm/api/app/build/dormitoryTreeByUseList',
            method: 'get',
            params
        }).then(res => {
          resolve(res.data)
        })
    })
}

export const getDeviceList = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: baseUrl + '/dorm/api/app/build/devInfoList',
            method: 'get',
            params
        }).then(res => {
          resolve(res.data)
        })
    })
}

export const importPerson = (data) => {
    return new Promise((resolve, reject) => {
        axios({
            url: baseUrl + '/dorm/api/app/build/importPerson',
            method: 'post',
            data
        }).then(res => {
          resolve(res.data)
        })
    })
}

export const importGroupPerson = (data) => {
    return new Promise((resolve, reject) => {
        axios({
            url: baseUrl + '/dorm/api/app/build/importGroupPerson',
            method: 'post',
            data
        }).then(res => {
          resolve(res.data)
        }).catch(err => {
            reject(err)
        })
    })
}

export const importPersonProgress = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: baseUrl + '/dorm/api/app/build/personImportDeviceProgress',
            method: 'get',
            params
        }).then(res => {
          resolve(res.data)
        })
    })
}

export const importPersonStatus = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: baseUrl + '/dorm/api/app/build/personImportDeviceStatus',
            method: 'get',
            params
        }).then(res => {
          resolve(res.data)
        })
    })
}
